Skip to content

analysis: reject calc_rh for chains shorter than 2 beads - #5371

Merged
jngrad merged 3 commits into
espressomd:pythonfrom
RudolfWeeber:fix/bug-46-calc-rh-chainlen1
Jul 15, 2026
Merged

analysis: reject calc_rh for chains shorter than 2 beads#5371
jngrad merged 3 commits into
espressomd:pythonfrom
RudolfWeeber:fix/bug-46-calc-rh-chainlen1

Conversation

@RudolfWeeber

Copy link
Copy Markdown
Contributor

The hydrodynamic radius is computed as a sum over distinct bead pairs
with a 0.5N(N-1) prefactor. For a single-bead chain (chain_length==1)
there are no pairs: the prefactor is 0 and the accumulated inverse
distance ri stays 0, so calc_rh evaluated prefac/ri = 0.0/0.0 = NaN and
returned a silent NaN array instead of reporting the ill-posed request.

check_topology only rejects chain_length<=0 and is shared with calc_re
and calc_rg, where single-bead chains are valid (R_e==0, R_g==0), so the
guard cannot live there. Add a calc_rh-specific precondition in the
script-interface dispatch that throws std::domain_error (surfaced as a
Python ValueError, consistent with the other chain-analysis domain
checks) when chain_length < 2.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

🤖 Generated with Claude Code

RudolfWeeber and others added 3 commits June 15, 2026 11:48
The hydrodynamic radius is computed as a sum over distinct bead pairs
with a 0.5*N*(N-1) prefactor. For a single-bead chain (chain_length==1)
there are no pairs: the prefactor is 0 and the accumulated inverse
distance ri stays 0, so calc_rh evaluated prefac/ri = 0.0/0.0 = NaN and
returned a silent NaN array instead of reporting the ill-posed request.

check_topology only rejects chain_length<=0 and is shared with calc_re
and calc_rg, where single-bead chains are valid (R_e==0, R_g==0), so the
guard cannot live there. Add a calc_rh-specific precondition in the
script-interface dispatch that throws std::domain_error (surfaced as a
Python ValueError, consistent with the other chain-analysis domain
checks) when chain_length < 2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jngrad jngrad changed the title analysis: reject calc_rh for chains shorter than 2 beads (bug-sweep #46) analysis: reject calc_rh for chains shorter than 2 beads Jul 15, 2026
@jngrad
jngrad marked this pull request as ready for review July 15, 2026 13:11

@jngrad jngrad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jngrad jngrad added the BugFix label Jul 15, 2026
@jngrad jngrad added this to the ESPResSo 5.0.2 milestone Jul 15, 2026
@jngrad
jngrad merged commit d0e3986 into espressomd:python Jul 15, 2026
10 checks passed
juliopas pushed a commit to juliopas/espresso that referenced this pull request Jul 16, 2026
…5371)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jngrad pushed a commit to jngrad/espresso that referenced this pull request Aug 10, 2026
…5371)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants